<template>
  <a-card :bordered='false'>
    <search :config='searchConfig' @search='search' @getHeight='getHeight' />
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        :border='true'
        :resizable='true'
        :showOverflow='true'
        size='mini'
        :loading='loading'
        :height='pageHeight-seachHeight-94'
        :align='left'
        :columns='columns'
        :data='dataSource'
        :toolbar-config='tableToolbar'
       :checkbox-config="checkboxConfig"
        v-bind='vexConfig'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button v-has="'proMinPrice:add'" @click='handleAdd'>新增</a-button>
            <a-button v-has="'proMinPrice:delete'" @click='batchDel'>删除</a-button>
<!--            <a-button type='primary' @click=''>同步</a-button>-->
<!--            <a-button type='primary' @click=''>导出</a-button>-->
          </div>
        </template>
        <template #detail='{ row,rowIndex }'>
          <a @click='handleDetail(row)'>{{ row.floorPriceRuleCode }}</a>
        </template>
        <template #date='{ row,rowIndex }'>
          {{ row.startDate }} ~ {{ row.endDate }}
        </template>
        <template #action='{ row }'>
          <a v-has="'proMinPrice:update'" @click='handleEdit(row)'>编辑</a>
          <a-divider type='vertical' />
          <a v-has="'business:log'" href='javascript:;' @click='handleBusiness("产品底价",row)'>日志</a>
        </template>
        <template #pager>
          <vxe-pager
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :currentPage.sync='ipagination.current'
            :page-size.sync='ipagination.pageSize'
            :total='ipagination.total'
            :pageSizes='ipagination.pageSizeOptions'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <business-log ref='businessLog'></business-log>
    <pro-min-price-modal ref="modalForm" @ok="modalFormOk"></pro-min-price-modal>
  </a-card>
</template>

<script>
import proMinPriceModal from './modules/ProMinPriceModal'
import { PageListMixin } from '@/mixins/PageListMixin'

export default {
  name: 'proMinPrice',
  mixins: [PageListMixin],
  components: {
    proMinPriceModal
  },
  data() {
    return {
      description: '产品底价',
      searchConfig: [
        {
          type: 'input',
          name: 'floorPriceRuleCode',
          placeholder: '底价规则编号'
        },
        {
          type: 'input',
          name: 'productCode',
          placeholder: '产品编号'
        },
        {
          type: 'input',
          name: 'productName',
          placeholder: '产品名称'
        },
        {
          type: 'date-range', //范围选择
          range: ['startDate', 'endDate'],
          name: 'range',
          format: 'YYYY-MM-DD',
          placeholder: ['生效开始时间', '生效结束时间']
        }
        ],
      columns: [
        { type: 'checkbox', width: 60, fixed: 'left' },
        {
          title: '底价规则编号',
          field: 'floorPriceRuleCode',
          minWidth: 100,
          fixed: 'left',
          slots: { default: 'detail' }
        },
        {
          title: '产品编号',
          minWidth: 100,
          field: 'productCode'
        },
        {
          title: '产品名称',
          minWidth: 100,
          field: 'productName'
        },
        {
          title: '产品底价',
          minWidth: 100,
          field: 'productFloorPrice'
        },
        {
          title: '生效时间',
          minWidth: 150,
          field: 'startDate',
          slots: { default: 'date' }
        },
        {
          title: '备注',
          minWidth: 100,
          field: 'remarks'
        },
        {
          title: '创建人',
          minWidth: 100,
          field: 'createName'
        },
        {
          title: '创建时间',
          minWidth: 100,
          field: 'createTime'
        },
        {
          title: '更新人',
          minWidth: 100,
          field: 'updateName'
        },
        {
          title: '更新时间',
          minWidth: 100,
          field: 'updateTime'
        },
        {
          title: '操作',
          align: 'center',
          minWidth: 120,
          fixed: 'right',
          slots: { default: 'action' }
        }
      ],
      url: {
        list: '/product-center/cnProductFloorPrice/findPageList',
        // detail: window._CONFIG['domianURL'] + '/product-center/cnProductFloorPrice/getInfo',
        delete: window._CONFIG['domianURL'] + '/product-center/cnProductFloorPrice/delete',
        deleteBatch: '/product-center/cnProductFloorPrice/deleteBatch',
        exportXlsUrl: '/test/cn-formDemo/exportXls'
      }
    }
  },
  created() {

    },
    methods:{

      handleEdit:async function(row) {
        this.$refs.modalForm.title='编辑'
        this.$refs.modalForm.edit(row)
        this.$refs.modalForm.disableSubmit = false
      },

      // search(queryParam, butType) {
      //   this.selectedRowKeys = []
      //   this.selectionRows = []
      //   this.queryParam = queryParam
      //   this.$refs.tableList.loadListData(queryParam)
      // },
    }
  }
</script>

<style scoped>
  @import '~@assets/less/common.less';
</style>